class CommonException(Exception):
    """公共异常类"""

    def __init__(self, enum_cls, errmsg=None, data=None):
        self.code = enum_cls.code
        self.errmsg = enum_cls.errmsg if errmsg is None else errmsg
        self.enum_cls = (self.code, self.errmsg)  # 这里需要构造状态码枚举类
        # self.data = data  # 可选是否携带数据
        self.data = data
        super().__init__()


class BusinessException(CommonException):
    """业务异常类"""
    pass


class APIException(CommonException):
    """接口异常类"""
    pass
